#include <stdio.h>
#include <string.h>
#define LINELENGTH 	80

void printarray(char a[])
{
	int i;
	for (i = 0; i < LINELENGTH; i++){
		printf("%s", a[i]);
	}
}

int fgetline(FILE *fp, char line[], int max)
{
	int c, i = 0;
	max = max - 1;
	while ((c = getc(fp)) != EOF){
		if ( c == '\n')
			break;
		if (i < max){
			line[i] = c;
			i++;
		}
	}
	if (c == EOF && i == 0){
		return EOF;
	}
	line[i] = '\0';
	return i;
}

int main(int argc, char* argv[]){
	FILE *first, *second;
	char line_first[LINELENGTH], line_second[LINELENGTH];
	if (argc < 3){
		printf ("Usage: %s <file1> <file2>\n", argv[0]);
		return (1);
	}
	
	if ((first = fopen(argv[1], "r")) == NULL){
		printf ("Error while opening the file %s\n", argv[1]);
		return (2);
	}
	if ((second = fopen(argv[2], "r")) == NULL){
		printf ("Error while opening the file %s\n", argv[2]);
		return (2);
	}
	while (fgetline(first, line_first, LINELENGTH) != EOF){
		fgetline(second, line_second, LINELENGTH);
		if (strcmp(line_first, line_second) != 0){
			printarray(line_first);
			printarray(line_second);

		}
	}
	fclose(first);
	fclose(second);
}
